package mochito.tools.syshook;


class PollThread extends Thread
{
	public native void checkKeyboardChanges();
	private KeyboardHook kbh;
 
	public PollThread( KeyboardHook kh )
	{
		kbh = kh;
		System.loadLibrary("syshook");
	}
 
	public void run()
	{
		for(;;)
		{
			checkKeyboardChanges();
			yield();
		}
	}
 
	void Callback( boolean ts, int vk, boolean ap, boolean ek )
	{
		KeyboardEvent event = new KeyboardEvent( this, ts, vk, ap, ek );
		if( ts )
		{
			kbh.keyPressed( event );
		}
		else
		{
			kbh.keyReleased( event );
		}
	}
}
